﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ElementsInfo.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the NavigationSetting type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Actions.Wss.Entities
{
    using System;
    using System.Xml.Serialization;

    using ContentType;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    [CollaborisClass(
       Title = "Elements Info",
       ReleaseStatus = ReleaseStatus.Beta,
       Summary = "Defines the parameters to specify a file containing CAML XML.")]
    [Serializable]
    public class ElementsInfo : WSSEntityBase
    {
        /// <summary>
        /// file path to the CAML File
        /// </summary>
        private string filePath;

        /// <summary>
        /// bool specifying whether to also remove columns.
        /// </summary>
        private bool? removeInChild;

        /// <summary>
        /// bool specifying whether to push changes down to the 
        /// child column or content type.
        /// </summary>
        private bool? pushChanges;
        
        [CollaborisProperty(
             Summary = "The local file path containing the CAML compliant XML file.",
             Title = "File Path",
             Example = @"${WorkingDirectory}\Elements.xml",
             Required = true,
             InputHint = InputHint.FileUrl,
             Remarks = "Currently only &lt;ContentTypes&gt; or &lt;Field&gt; " +
                        @"elements are supported."
        )]
        public string FilePath 
        {
            get
            {
                return this.filePath;
            }

            set 
            {
                this.filePath = value;
            } 
        }

        [CollaborisProperty(
             Summary = "Specifies whether to remove the columns " + 
                        "from the child content types if they are resident.",
             Title = "Remove In Child",
             Example = @"false",
             Required = false,
             InputHint = InputHint.Boolean,
             Remarks =  " If this entity is used within the 'EnsureContentType' action " + 
                        " then specifying 'True' will remove the fields in the child content" + 
                        " types. (This may result in loss of data)." 
        
        )]
        [XmlElement(IsNullable = true)]
        public bool? RemoveInChild
        {
            get
            {
                return this.removeInChild;
            }

            set
            {
                this.removeInChild = value;
            }
        }

        

        [Obsolete]
        [XmlElement(IsNullable = true)]
        public bool? UndoRemoveContentTypes
        {
            get
            {
                return this.removeInChild;
            }

            set
            {
                this.removeInChild = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <remarks>
        /// <para>
        /// If this entity is used within the <see cref="EnsureContentType"/>
        /// then specifying 'True' will 
        /// Child Content Type (usually associated with a list). 
        /// </para>
        /// <para>
        /// If this entity is used within the <see cref="EnsureContentType"/>
        /// then specifying 'False' will prevent any changes being propogated to the
        /// Child Content Type. However, the changes will be applied to the Content
        /// Type that is specified by the "ID" attribute in the CAML file.
        /// </para>
        /// </remarks>
        [CollaborisProperty(
             Summary = "Specifies whether to push the changes down to the underlying child content types or child columns.",
             Title = "Remove In Child",
             Example = @"false",
             Required = false,
             InputHint = InputHint.Boolean,
             Remarks =  " If this entity is used within the 'EnsureContentType' action " +
                        " then specifying 'True' will cause any changes to " + 
                        "be propogated to the child content type (usually associated with a list)."
        )]
        [XmlElement(IsNullable = true)]
        public bool? PushChangesToList
        {
            get
            {
                return this.pushChanges;
            }

            set
            {
                this.pushChanges = value;
            }
        }
    }
}